package com.easy.modules.sysmgr.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import com.easy.modules.common.RecordEntity;

/**
 * 类描述：用户组管理 
 * 创建时间： 2014-5-28 下午5:02:32
 * 创建者： 杨浩泉
 * 版本号： v1.0
 */
@Entity
@Table(name = "EASY_SYSMGR_USER_ROLE")
@DynamicUpdate(true)
@DynamicInsert(true)
public class UserRoleEntity extends RecordEntity {

	private String name ;		//用户工作组名称
	
	private String remark ;		//用户工作组描述

	private Set<UserEntity> users = new HashSet<UserEntity>(0) ;					//用户
	
	private Set<PermitsEntity> permits = new HashSet<PermitsEntity>(0) ;			//权限组
	
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "EASY_SYSMGR_USERROLE_PERMITS", joinColumns = { @JoinColumn(name = "USERROLE_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "PERMITS_ID", nullable = false, updatable = false) })
	public Set<PermitsEntity> getPermits() {
		return permits;
	}

	public void setPermits(Set<PermitsEntity> permits) {
		this.permits = permits;
	}
	
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "EASY_SYSMGR_USER_USERROLE", joinColumns = { @JoinColumn(name = "USERROLE_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "USER_ID", nullable = false, updatable = false) })
	public Set<UserEntity> getUsers() {
		return users;
	}

	public void setUsers(Set<UserEntity> users) {
		this.users = users;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

}
